import {createStore} from 'vuex'
import createPersistedState from "vuex-persistedstate"

export default createStore({
	state: {
		StudentTerminalCurrentComponent: 'PersonalInformationView',
		AdminTerminalCurrentComponent: 'UserManagementView',
		DepartmentTerminalCurrentComponent: 'DepartmentInformationManagementView',
		CurrentUser: '',
		CurrentDepartment:''
	},
	mutations: {
		setCurrentUser(state, user) {
			state.CurrentUser = user;
		},
		setDepartment(state, department) {
			state.CurrentDepartment = department;
		},
		setStudentTerminalCurrentComponent(state, componentName) {
			state.StudentTerminalCurrentComponent = componentName;
		},
		setAdminTerminalCurrentComponent(state, componentName) {
			state.AdminTerminalCurrentComponent = componentName;
		},
		setDepartmentTerminalCurrentComponent(state, componentName) {
			state.DepartmentTerminalCurrentComponent = componentName;
		},
	},
	getters: {
		CurrentUser: (state) => state.CurrentUser,
	},
	actions: {
		setStudentTerminalCurrentComponentAction({commit}, componentName) {
			commit('setStudentTerminalCurrentComponent', componentName);
		},
		setAdminTerminalCurrentComponentAction({commit}, componentName) {
			commit('setAdminTerminalCurrentComponent', componentName);
		},
		setDepartmentTerminalCurrentComponentAction({commit}, componentName) {
			commit('setDepartmentTerminalCurrentComponent', componentName);
		},
	},
	modules: {},
	plugins: [createPersistedState()]
})
